package com.gesee.zyspps.adapter;

import java.util.List;

import com.gesee.zys.R;
import com.gesee.zyspps.db.CmsDbNum;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 
* @ClassName: ExistenceProjectAdater
* @Description: TODO(存在的工程文件)
* @author fujianxiong
* @date 2015年8月23日 上午1:13:10
*
 */
public class ExistenceProjectAdater extends BaseAdapter
{
    private Context mContext;
    private List<CmsDbNum> projectList;

    public ExistenceProjectAdater(Context ctx)
    {
        this.mContext = ctx;
    }

    public void setList(List<CmsDbNum> projectList)
    {
        this.projectList = projectList;
    }

    public List<CmsDbNum> getList()
    {
        return projectList;
    }

    public int getCount()
    {
        return projectList == null ? 0 : projectList.size();
    }

    public Object getItem(int position)
    {
        return projectList.get(position);
    }

    public long getItemId(int position)
    {
        //return projectList.get(position).getId();
    	return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder holder = null;
        if (convertView == null)
        {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.project_list, null);
            holder = new ViewHolder();
            holder.tv_project_name = (TextView) convertView.findViewById(R.id.tv_project_name);
            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }
        
        CmsDbNum dbNum = (CmsDbNum) getItem(position);

        holder.tv_project_name.setText(dbNum.getDbName());

        return convertView;
    }

    class ViewHolder
    {
        TextView tv_project_name;
    }

}
